package com.iflytek.exam.service.impl;

import java.util.List;
import com.iflytek.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iflytek.exam.mapper.UserStudentMapper;
import com.iflytek.exam.domain.UserStudent;
import com.iflytek.exam.service.IUserStudentService;

/**
 * 用户信息Service业务层处理
 *
 * @author Dogdog
 * @date 2024-07-08
 */
@Service
public class UserStudentServiceImpl implements IUserStudentService
{
    @Autowired
    private UserStudentMapper userStudentMapper;

    /**
     * 查询用户信息
     *
     * @param userId 用户信息主键
     * @return 用户信息
     */
    @Override
    public UserStudent selectUserStudentByUserId(Long userId)
    {
        return userStudentMapper.selectUserStudentByUserId(userId);
    }

    /**
     * 查询用户信息列表
     *
     * @param userStudent 用户信息
     * @return 用户信息
     */
    @Override
    public List<UserStudent> selectUserStudentList(UserStudent userStudent)
    {
//        ArrayList arrayList = new ArrayList();
//        List<UserStudent> userStudents = userStudentMapper.selectUserStudentList(userStudent);
//        for (int i = 0; i < userStudents.size(); i++){
//            Long userId = userStudents.get(i).getUserId();
//            arrayList.add(userId);
//        }
//        List list = userStudentMapper.selectRoleByUserId(arrayList);
        return userStudentMapper.selectUserStudentList(userStudent);
    }

    /**
     * 新增用户信息
     *
     * @param userStudent 用户信息
     * @return 结果
     */
    @Override
    public int insertUserStudent(UserStudent userStudent)
    {
        userStudent.setCreateTime(DateUtils.getNowDate());
        return userStudentMapper.insertUserStudent(userStudent);
    }

    /**
     * 修改用户信息
     *
     * @param userStudent 用户信息
     * @return 结果
     */
    @Override
    public int updateUserStudent(UserStudent userStudent)
    {
        userStudent.setUpdateTime(DateUtils.getNowDate());
        return userStudentMapper.updateUserStudent(userStudent);
    }

    /**
     * 批量删除用户信息
     *
     * @param userIds 需要删除的用户信息主键
     * @return 结果
     */
    @Override
    public int deleteUserStudentByUserIds(Long[] userIds)
    {
        return userStudentMapper.deleteUserStudentByUserIds(userIds);
    }

    /**
     * 删除用户信息信息
     *
     * @param userId 用户信息主键
     * @return 结果
     */
    @Override
    public int deleteUserStudentByUserId(Long userId)
    {
        return userStudentMapper.deleteUserStudentByUserId(userId);
    }
}
